package com.ant.temple.myview;

import java.util.Random;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class AntCircle extends View {

	private Paint paint;
	private float r=10,p=1f,speed=5f,x=200f,y=200f;
	public AntCircle(Context context) {
		super(context);
	}

	public AntCircle(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}
	public AntCircle(Context context, AttributeSet attrs) {
		super(context, attrs);

		paint = new Paint();
		Random rand = new Random(255);
		paint.setColor(Color.rgb(rand.nextInt(), rand.nextInt(), rand.nextInt()));
		paint.setStyle(Paint.Style.FILL);
		paint.setStrokeWidth(2f);

	}


	@Override
	protected void onDraw(Canvas canvas) {
		canvas.drawColor(Color.BLACK);
		super.onDraw(canvas);
		if(r>=200){
			r=1;
			x=(float)(Math.random()*500);
			y=(float)(Math.random()*500);
		}
		paint.setAlpha((int)(200-r));
		canvas.drawCircle(x, y, r=r+speed, paint);
		//		canvas.draw
		invalidate();
	}

}
